package communication.message;

/***
 * 
 * @author Bogusław Zaręba
 *
 */

public class XMLTagCreator {
	public static String openTag(String name) {
		return '<' + name + '>';
	}
	
	public static String openTag(String name, String attr1, String val1) {
		return '<' + insideTag(name, attr1, val1) + '>';
	}
	
	public static String openTag(String name, String attr1, String val1, String attr2, String val2) {
		return '<' + insideTag(name, attr1, val1, attr2, val2) + '>';
	}
	
	public static String closeTag(String name) {
		return "</" + name + '>';
	}	
	
	public static String singleTag(String name, String attr1, String val1) {
		return '<' + insideTag(name, attr1, val1) + "/>";
	}
	
	public static String singleTag(String name, String attr1, String val1, String attr2, String val2) {
		return '<' + insideTag(name, attr1, val1, attr2, val2) + "/>";
	}
	
	public static String singleTag(
		String name, String attr1, String val1, String attr2, String val2,
		String attr3, String val3
	) {
		return '<' + insideTag(name, attr1, val1, attr2, val2, attr3, val3) + "/>";
	}
	
	public static String singleTag(
		String name, String attr1, String val1, String attr2, String val2,
		String attr3, String val3, String attr4, String val4
	) {
		return '<' + insideTag(name, attr1, val1, attr2, val2, attr3, val3, attr4, val4) + "/>";
	}
	
	private static String insideTag(String name, String attr1, String val1) {
		return name + ' ' + attr1 + "=\"" + val1 + "\"";
	}
	
	private static String insideTag(String name, String attr1, String val1, String attr2, String val2) {
		return insideTag(name, attr1, val1) + ' ' + attr2 + "=\"" + val2 + "\""; 
	}
	
	private static String insideTag(
		String name, String attr1, String val1, String attr2, String val2,
		String attr3, String val3
	) {
			return insideTag(name, attr1, val1, attr2, val2 ) + ' ' + attr3 + "=\"" + val3 + "\""; 
	}
	
	private static String insideTag(
		String name, String attr1, String val1, String attr2, String val2,
		String attr3, String val3, String attr4, String val4
	) {
		return insideTag(name, attr1, val1, attr2, val2, attr3, val3) + ' ' + attr4 + "=\"" + val4 + "\""; 
	}
}
